package data

import (
	"fmt"
)

type TimeNew struct {
	hour, minute, second int64
}

// NewSecond 将秒数转化为时分秒
func NewSecond(second int64) *TimeNew {
	// 各时间进制关系
	var (
		minuteSecond int64 = 60
		hourSecond         = 60 * minuteSecond
	)
	// 小时
	hour := second / hourSecond
	// 分钟
	minute := (second % hourSecond) / minuteSecond
	// 秒
	second = (second % hourSecond) % minuteSecond
	return &TimeNew{
		hour:   hour,
		minute: minute,
		second: second,
	}
}

func (nt *TimeNew) Second() int64 {
	return nt.second
}

func (nt *TimeNew) Hour() int64 {
	return nt.hour
}

func (nt *TimeNew) Minute() int64 {
	return nt.minute
}

func (nt *TimeNew) String() string {
	return fmt.Sprintf("%02d:%02d:%02d", nt.hour, nt.minute, nt.second)
}
